package com.xiaohu.common;

/**
 * 分页实体类
 */
public class PageHelper {
    /**
     * 每页显示的条数
     */
    private int limit;

    /**
     * 第几页
     */
    private int page;

    /**
     * 分页关键字limit开始下标
     */
    private int start;

    /**
     * 分页关键字limit结束下标
     */
    private int end;

    /**
     * 总条数
     */
    private int count;

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
        if (this.page > 0 && this.limit > 0) {
            this.start = (this.page - 1) * this.limit;
            this.end = this.limit;
        }
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
        if (this.page > 0 && this.limit > 0) {
            this.start = (this.page - 1) * this.limit;
            this.end = this.limit;
        }
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getEnd() {
        return end;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public PageHelper() {
    }

    public PageHelper(int limit, int page, int start, int end, int count) {
        this.limit = limit;
        this.page = page;
        this.start = start;
        this.end = end;
        this.count = count;
    }

    @Override
    public String toString() {
        return "PageHelper{" +
                "limit=" + limit +
                ", page=" + page +
                ", start=" + start +
                ", end=" + end +
                ", count=" + count +
                '}';
    }
}
